from selenium.webdriver.common.by import By
from pages.base_page import BasePage





class RecycleBinPage(BasePage):
    url = "/crm/index.php?m=leads&a=index&by=deleted"
    result_locator = (By.XPATH, '/html/body/div[5]/div[2]')
    error_locator =(By.XPATH,"/html/body/div/form/fieldset/div[1]")
    clue_locator = (By.LINK_TEXT, '线索')
    choose1_locator = (By.XPATH, '//*[@id="form1"]/table/tbody/tr[1]/td[1]/input')
    choose2_locator = (By.XPATH, '//*[@id="form1"]/table/tbody/tr[2]/td[1]/input')
    choose3_locator = (By.XPATH, '//*[@id="form1"]/table/tbody/tr[4]/td[1]/input')
    btn_dropdown_toggle_locator = (By.XPATH, "/html/body/div[5]/div[2]/div[1]/ul/li[1]/div/a")
    delete_locator = (By.ID, "delete")
    restore_locator = (By.XPATH, '//*[@id="form1"]/table/tbody/tr[2]/td[11]/a[2]')  # 还原
    tips_locator = (By.CSS_SELECTOR, 'body > div.container > div.alert.alert-success')   # 操作后提示
    def click_clue(self):
        """
        点击线索
        """
        self.find_element(self.clue_locator).click()
    def choose1_clue(self):
        """
        选择要删掉的线索
        """
        self.find_element(self.choose1_locator).click()
    def choose2_clue(self):
        """
        选择要删掉的线索
        """
        self.find_element(self.choose2_locator).click()
    def choose3_clue(self):
        """
        选择要删掉的线索
        """
        self.find_element(self.choose3_locator).click()
    def dropdown_toggl_clue(self):
        """
        点击批量操作
        """
        self.find_element(self.btn_dropdown_toggle_locator).click()
    def delete_clue(self):
        """
        点击批量删除
        """
        self.find_element(self.delete_locator).click()

    def click_delete_btn(self):
        """
        点击删除按钮
        """
        self.find_element(self.restore_locator).click()

    def click_restore_btn(self):
        """
        点击还原按钮
        """
        self.find_element(self.restore_locator).click()

#返回增删改查后的提示信息
    def get_result_tips(self):
        return self.find_element(self.result_locator).text

#返回弹窗文本信息
    def get_alert_text(self):
        return self.driver.switch_to.alert.text

#返回报错弹窗文本信息
    def get_error_text(self):
        return self.find_element(self.error_locator).text


